package com.neuedu.security.controller;

import com.neuedu.security.model.Category;
import com.neuedu.security.model.RespBean;
import com.neuedu.security.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    @PostMapping("/addCategory")
    public RespBean addCategory(@RequestBody Category category) {
        return categoryService.addCategory(category);
    }

    @DeleteMapping("/delCategory/{id}")
    public RespBean delCategory(@PathVariable int id) {
        return categoryService.delCategory(id);
    }

    @DeleteMapping("/delCategories")
    public RespBean delCategories(int[] ids) {
        return categoryService.delCategories(ids);
    }

    @PutMapping("/updateCategory")
    public RespBean updateCategory(@RequestBody Category category) {
        return categoryService.updateCategory(category);
    }

    @GetMapping("/getCategory")
    public List<Category> getCategory(String keyWords) {
        return categoryService.getCategory(keyWords);
    }
}
